package com.baomidou.mybatisplus.criterion;

/**
 * superclass for comparisons between two properties (with SQL binary operators)
 * @author Timothy Ren
 */
public class PropertyExpression implements QueryCriterion {

	private static final long serialVersionUID = 1L;
	private static final Object[] NO_TYPED_VALUES = new Object[0];

	private final String propertyName;
	private final String otherPropertyName;
	private final String op;

	protected PropertyExpression(String propertyName, String otherPropertyName, String op) {
		this.propertyName = propertyName;
		this.otherPropertyName = otherPropertyName;
		this.op = op;
	}

	public String getOp() {
		return op;
	}

	public String toSqlString() {
		return new StringBuffer().append(propertyName).append(getOp()).append(otherPropertyName).toString();
	}

	public Object[] getValueArr() {
		return NO_TYPED_VALUES;
	}

	public String toString() {
		return propertyName + getOp() + otherPropertyName;
	}
}
